import { getCookie, setCookie } from "@/utils";
import { createSlice } from "@reduxjs/toolkit";

export const ProductID = createSlice({
  name: 'productID',
  initialState: {
    value: getCookie('id') || 0
  },
  reducers: {
    saveID (state, action) {
      state.value = action.payload
      setCookie('id', action.payload) 
    }
  }
})

export const { saveID } = ProductID.actions
export default ProductID.reducer